import os
import sys
import logic_function_module as logic_class  # 逻辑函数类

from flask import Flask, request

grand_parent_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.append(grand_parent_dir)
print(sys.path)


app = Flask(__name__)


@app.route('/call', methods=['GET', 'POST', 'PUT', 'DELETE'])
def call_function():
    function_name = request.args.get('function_name')
    function_to_call = getattr(logic_class, function_name)
    return function_to_call()


if __name__ == '__main__':
    app.run(host="0.0.0.0", port=5000)  # 端口默认是5000，需要check是否可以调用，不行的话加端口到白名单中
